package com.erp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.erp.common.CustomException;
import com.erp.dao.ManagerGroupDao;
import com.erp.entity.ManagerGroup;
import com.erp.service.ManagerGroupService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ManagerGroupServiceImpl extends ServiceImpl<ManagerGroupDao, ManagerGroup> implements ManagerGroupService {
    @Override
    public String findManagerName(Long managerId) {
        LambdaQueryWrapper<ManagerGroup> managerGroupLambdaQueryWrapper = new LambdaQueryWrapper<>();
        managerGroupLambdaQueryWrapper.eq(ManagerGroup::getManagerId,managerId);
        List<ManagerGroup> list = this.list(managerGroupLambdaQueryWrapper);
        if (list.size()>1){
            throw new CustomException("管理员表异常，请联系管理员维护");
        }
        ManagerGroup managerGroup = list.get(0);
        return managerGroup.getManagerName();
    }
}
